<template>
    <view>
        <!-- parse <include src="../component/navigationBar.wxml"></include> -->
        <block>
            <view class="navigationBox" :style="'padding-top:' + nTop + 'px;height:' + nHeight + 'px;line-height:' + nHeight + 'px;--color:' + color + ';'">
                <view class="nBar" :style="'height:' + nHeight + 'px;top:' + nTop + 'px'">
                    <navigator class="ico" hoverClass="none" :openType="pages.length == 1 ? 'switchTab' : 'navigateBack'" :url="pages.length == 1 ? '/pages/index/index4' : ''">
                        {{ pages.length == 1 ? '' : '' }}
                    </navigator>
                    <view class="title">{{ nTitle }}</view>
                </view>
            </view>
        </block>
        <scroll-view
            @refresherrefresh="onPullDownRefresh"
            @scroll="binnd_scroll"
            @scrolltolower="onReachBottom"
            class="list"
            :enableBackToTop="true"
            :enableFlex="true"
            lowerThreshold="300"
            :refresherEnabled="true"
            :refresherTriggered="triggered"
            :scrollTop="scrolltopNum_index"
            :scrollWithAnimation="true"
            :scrollY="true"
            :style="'margin-top:' + nTH + 'px;height:-webkit-calc(100vh - ' + nTH + 'px);--color:' + color + ';--rgbcolor:' + rgbcolor + ';'"
        >
            <view class="tab2">
                <view @tap="tFn" :class="'a' + (globalUtils.empty(t) ? ' ed' : '')" data-t="0">
                    <view class="i _new ico"></view>
                    <text class="span">推荐</text>
                </view>
                <view @tap="tFn" :class="'a' + (t == 1 ? ' ed' : '')" data-t="1">
                    <view class="i _flag1 ico"></view>
                    <text class="span">报名中</text>
                </view>
                <view @tap="tFn" :class="'a' + (t == 2 ? ' ed' : '')" data-t="2">
                    <view class="i _flag2 ico"></view>
                    <text class="span">进行中</text>
                </view>
                <view @tap="tFn" :class="'a' + (t == 3 ? ' ed' : '')" data-t="3">
                    <view class="i _flag3 ico"></view>
                    <text class="span">已结束</text>
                </view>
            </view>
            <block v-if="LIST.length > 0" v-for="(dl, index) in LIST" :key="index">
                <navigator hoverClass="none" :url="'party_detail?fid=' + item.fid" v-for="(item, index1) in dl" :key="index1">
                    <view class="h3">{{ item.title }}</view>

                    <view class="pic">
                        <image mode="aspectFill" :src="item.path_b"></image>
                    </view>

                    <view class="djs">
                        <view class="font">
                            <block v-if="item.DJS.flag == 1">
                                <text class="sapn jzbmT">
                                    <text class="ico"></text>
                                    {{ item.DJS.title }}
                                </text>
                                <block v-for="(item2, index2) in item.DJS.djstime" :key="index2">
                                    <text class="sapn timestyle">{{ item2.num }}</text>

                                    {{ item2.t }}
                                </block>
                            </block>
                            <block v-else>{{ item.DJS.title }}</block>
                        </view>
                    </view>

                    <view class="dl">
                        <view class="dd">
                            <block v-if="item.bmulist.length > 0">
                                <image mode="aspectFill" :src="item3" v-for="(item3, index2) in item.bmulist" :key="index2"></image>
                            </block>
                            <text class="nobm" v-else>暂时还没有人报名</text>
                            <view class="partyflag">
                                <text :class="'span partyflag' + item.bmflag.f">{{ item.bmflag.t }}</text>
                            </view>
                        </view>
                    </view>
                </navigator>
            </block>
            <view class="nodata" v-if="party_nodata && LIST.length == 0">
                <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
                暂无符合条件的内容　
                <text @tap="nodatabackFn" data-sokind="default" :style="'color:' + color">返回</text>
            </view>
            <view class="loading" v-if="loading_flag">
                <image class="loading_ico" src="/static/res/img/loading_ico.svg" v-if="loading_ico_flag"></image>
                <text>{{ loading_str }}</text>
            </view>
            <view class="blank">　</view>
        </scroll-view>
        <view @tap="backtopFn" class="backtop fadeInUp" data-id="index" :style="'color:' + color" v-if="backtop_flag">
            <text class="ico icon-backtop"></text>
            顶部
        </view>
    </view>
</template>
<script>
import globalUtils from "../../res/www.a9a.cn";

var t;
var a = require('../../@babel/runtime/helpers/defineProperty');
var i = require('../../res/www.a9a.cn.js');
var app = getApp();
var e = 2;
var o = true;
export default {
  computed: {
    globalUtils() {
      return globalUtils
    }
  },
    data() {
        return {
            aid: 0,
            nTitle: '相亲活动',
            t: 0,
            triggered: true,
            loading_flag: false,
            loading_ico_flag: false,
            loading_str: '玩命加载中',
            color: '',
            rgbcolor: '',
            LIST: [],
            party_nodata: false,
            SHARE: '',
            backtop_flag: false,
            nTop: '',
            nHeight: '',
            pages: [],
            scrolltopNum_index: 0,
            nTH: '',
            dl: []
        };
    },
    onLoad: function (t) {
        var that = this;
        uni.setNavigationBarTitle({
            title: that.nTitle
        });
        app.globalData.get_config('_ZEAI').then(function (t) {
            that.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: i.c16_rgb(app.globalData._ZEAI.color)
            });
        });
        app.globalData.get_navigationBarTopHeight(that);
        this.init();
    },
    onPullDownRefresh: function () {
        var that = this;
        uni.vibrateShort({
            type: 'heavy'
        });
        setTimeout(function () {
            that.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                party_nodata: false,
                t: 0
            });
            that.setloading('end', '拼命加载中');
            e = 2;
            that.init();
        }, 500);
    },
    onReachBottom: function () {
        var i = this.LIST;
        var that = this;
        if (o) {
            o = false;
            that.setloading('start', '拼命加载中');
            var l = {
                submitok: 'party',
                p: e,
                openid: t.openid,
                t: that.t,
                aid: app.globalData.aid
            };
            app.globalData.ajax({
                url: 'party.php',
                data: l,
                success: function (t) {
                    if (1 == t.flag) {
                        var n = i.length;
                        if (t.LIST.length < 1) {
                            that.setloading('end', '已全部加载完毕');
                            return void (o = false);
                        }
                        that.setData(a({}, 'LIST[' + n + ']', t.LIST));
                        e += 1;
                        o = true;
                    } else {
                        uni.showToast({
                            title: t.msg,
                            icon: 'none',
                            mask: true
                        });
                    }
                    that.setloading('end', '上拉加载更多');
                }
            });
        }
    },
    onShareAppMessage: function (t) {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            path: '/pagesA/party/party?aid=' + app.globalData.aid
        };
    },
    onShareTimeline: function () {
        return {
            imageUrl: this.SHARE.imgurl,
            title: this.SHARE.title,
            query: 'aid=' + app.globalData.aid,
            path: '/pagesA/party/party'
        };
    },
    methods: {
        init: function () {
            var that = this;
            uni.showLoading({
                title: '玩命加载中...',
                mask: true
            });
            o = false;
            t = uni.getStorageSync('COOK_U');
            app.globalData.ajax({
                url: 'party.php',
                data: {
                    submitok: 'party',
                    openid: t.openid,
                    t: that.t,
                    aid: app.globalData.aid
                },
                success: function (t) {
                    var n;
                    if (1 == t.flag) {
                        if (0 == t.LIST.length) {
                            that.setData({
                                LIST: [],
                                party_nodata: true,
                                nTitle: t.nTitle,
                                SHARE: t.SHARE
                            });
                        } else {
                            that.setData((a((n = {}), 'LIST[0]', t.LIST), a(n, 'nTitle', t.nTitle), a(n, 'SHARE', t.SHARE), n));
                        }
                    } else {
                        uni.showToast({
                            title: t.msg,
                            icon: 'none',
                            mask: true
                        });
                    }
                    o = true;
                    uni.hideLoading();
                }
            });
        },

        tFn: function (t) {
            var a = t.currentTarget.dataset.t;
            this.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                party_nodata: false,
                t: a
            });
            this.init();
        },

        nodatabackFn: function () {
            this.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                party_nodata: false,
                t: 0
            });
            this.init();
        },

        setloading: function (t, a) {
            'start' == t
                ? this.setData({
                      loading_flag: true,
                      loading_ico_flag: true,
                      loading_str: a
                  })
                : this.setData({
                      loading_flag: false,
                      loading_ico_flag: false,
                      loading_str: a
                  });
        },

        binnd_scroll: function (t) {
            t.detail.scrollTop > 100
                ? this.setData({
                      backtop_flag: true
                  })
                : this.setData({
                      backtop_flag: false
                  });
        },

        backtopFn: function (t) {
            var i = 'scrolltopNum_' + t.currentTarget.dataset.id;
            this.setData(a({}, i, 0));
        },

        onPullDownRefresh() {
            console.log('占位：函数 onPullDownRefresh 未声明');
        },

        onReachBottom() {
            console.log('占位：函数 onReachBottom 未声明');
        }
    }
};
</script>
<style>
@import 'party.css';
</style>
